package cn.heycm.blog.console.domain.admin.model;

import cn.heycm.blog.common.entity.session.Session;
import cn.heycm.blog.common.utils.RandomUtil;
import lombok.Builder;
import lombok.Getter;

/**
 * 管理员
 *
 * @author hey
 * @version 1.0
 * @since 2024/9/15 18:49
 */
@Builder
@Getter
public class Administrator {

    private int id;

    private int roleId;

    private String phoneId;

    private boolean enable;

    private String username;

    private String nickname;

    public boolean ifAllowLogin() {
        return enable;
    }

    public Session buildSession() {
        return Session.builder()
                .userId(id)
                .roleId(roleId)
                .username(username)
                .phoneId(phoneId)
                .token(RandomUtil.uuid())
                .build();
    }
}
